Configuring Git
Pre-requisites
Download and install WinMerge. Make sure this is in the path (turn on the Add WinMerge folder to your system path switch) when you install this. We will configure Git to use this as a diff tool, and the Flux.Test system also uses WinMerge to display differences in text files when tests fail.
Download and install Notepad++. We will configure this as the message editor for Git.
Download and install P4Merge. We will use this as the 3-way merge tool for Git.
Git Installation
Download and install git from git-scm.com/downloads/win.
Overrides from the default installation process are listed below. The headings in bold are the Git Setup dialog pages, and the notes below are the recommendations for that page.
Select Components
Make sure to turn on the check-box to install Git LFS (Large File Support)
Choosing the default editor used by Git
Install Notepad++ first, and during the Git installation, select that as the default editor.
Adjusting the name of the initial branch in new repositories
Override the default branch name for new repositories, and set that to main (this is what we are using for the Flux repositories).
Configuring the line ending conversions
Make sure to select Checkout as-is, commit as-is. In short, we don’t want any LF to CRLF conversions or vice versa. We have a lot of text and HTML files in our test-data set that use Unix style endings and this conversion will cause tests to fail.
Configuring the terminal emulator to use with Git Bash
I recommend that you choose to use the Windows Default Console window than to use MinTTY.
Choose the default behavior of "git pull"
Make sure to select Only ever fast-forward. This is especially important for folks like us who are coming over from Mercurial. By default a git pull will do a merge of the incoming commit, and that is usually not what you want unless we can do a fast-forward merge. The equivalent to a hg pull is really a git fetch and then one can do a git merge appropriately. I think this is definitely better than doing silent merges of the non-fast-forward variety.
Choose a credential helper
Pick the Git Credential Manager Core - this will make it easy to log in just once to Github and you will not keep seeing name and password prompts each time.
One-time Git setup
Edit your global git configuration file using:
git config --global --edit
This should open up notepad and load your global config file. Edit your config file, and make it look similar to the config file I have listed below (change the email and name, of course). Note that I have installed the tools like notepad, winmerge etc to the C:/Apps folder, and so my config uses those paths. If you use a different path (like Program Files, make the appropriate changes).
[user]
email = gandalf@shire.com (1)
name = gandalf (2)
[http]
proxy = http://%username%@srv34prox.corp.trumpf.com:80
sslBackend = schannel
#credential.helper wincred
#sslCAInfo = c:\\Users\\%username%\\ca-bundle.trust.crt
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[core]
autocrlf = false
whitespace = -trailing-space,cr-at-eol
editor = 'C:/Apps/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin
[alias]
st = status
sw = switch
di = difftool --dir-diff
tip = log -1 head
undo = restore
lg = log -n 20 --graph --format='%h %C(yellow)%an%Creset %C(green)%as%Creset %s %C(brightblue)%d%Creset'
find = log --format='%h %C(yellow)%an%Creset %C(green)%as%Creset %s %C(brightblue)%d%Creset' --grep
[diff]
tool = winmerge
[difftool]
prompt = true
[difftool "winmerge"]
cmd = 'C:/Apps/WinMerge/WinMergeU.exe' -e -r -dl \"Old $BASE\" -dr \"New $BASE\" \"$LOCAL\" \"$REMOTE\"
trustExitCode = true
[merge]
tool = P4Merge
conflictstyle = diff3
[mergetool]
prompt = true
[mergetool "P4Merge"]
path = 'C:/Apps/P4Merge/P4Merge.exe'
keepBackup = false
[credential]
helper = wincred
[credential "http://srv34prox.corp.trumpf.com"]
provider = generic
| 1 | Your TRUMPF email address |
| 2 | Your name as you want it to appear in Git commit messages. Preferably, use your TRUMPF username, so that it’s easier for others to identify you in commit history. |
Git aliases
Note that the git configuration file above has a number of entries in the [alias] section. These
set up aliases, or shortcuts that can simplify your use of git. For example, even though we have
set up WinMerge as out diff tool, the normal git diff command will not use it (it will output
the results to the console). To use the diff tool, you need to use git difftool --dir-diff. This
can get tedious to keep typing each time, so I have set up an alias called git di to do just this.
Likewise, the git st (for status), git undo to revert changes back and git sw to switch to
a different branch are useful shortcuts. We also set up git find as a shortcut to search through
commit messages. For example, here’s a typical interaction, where we are trying to find the commits
related to a particular case:
Similarly, the git lg shortcut is useful to provide a quick view at recent history:
You can create your own aliases by editing the global config file, using git config --global --edit.
Set Proxy for Trumpf Network
Working with Trumpf’s computer and network requires proxy to be enabled to access external websites.Set the environment variable, which must be mapped to a local folder in C: drive. Create and use the Visual Studio projects in this local folder.
Create a new folder inside C: drive and name it Work.
Open the command prompt and type the command SETX HOME C:\Work to set the work as your local folder.
Modify the proxy server setting by typing the below command in the command prompt window:
Git config --global http.proxy http://WindowsLoginID@srv34prox.corp.trumpf.com:80
Git config --global http.sslverify false
| WindowsLoginID must be substituted with your Windows username. |
Type the following command to enable proxy for Trumpf network:
setx HTTPS_PROXY http://WindowsLoginID@srv34prox.corp.trumpf.com:80
setx HTTP_PROXY http://WindowsLoginID@srv34prox.corp.trumpf.com:80